﻿using AutoMapper;
using MediatR;
using S.Initial.API.Application.Command.BreedingMothers;
using S.Initial.Domain;
using S.Initial.Infrastructure.Interface;

namespace S.Initial.API.Application.CommandHandlers.BreedingMothers
{
    /// <summary>
    /// 种母修改
    /// </summary>
    public class UpdateBreedingMothersCommandHandler : IRequestHandler<UpdateBreedingMothersCommand, int>
    {
        private readonly IBreedingMothersRepository breeding;
        private readonly IMapper mapper;

        public UpdateBreedingMothersCommandHandler(IBreedingMothersRepository breeding, IMapper mapper)
        {
            this.breeding = breeding;
            this.mapper = mapper;
        }
        public async Task<int> Handle(UpdateBreedingMothersCommand request, CancellationToken cancellationToken)
        {
            return await breeding.UpdateBreedingmothers(mapper.Map<BreedMaleAndFemaleStart>(request));
        }
    }
}
